package com.example.sportgoods.Service.impl;

import com.example.sportgoods.domain.Goods;
import com.example.sportgoods.domain.Order;
import com.example.sportgoods.mapper.OrderMapper;
import com.example.sportgoods.Service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    // 获取所有订单的业务方法，调用OrderMapper的对应方法从数据库获取所有订单记录
    @Override
    public List<Order> selectAllOrders() {
        return orderMapper.getAllOrders();
    }

    // 根据订单id查询单个订单的业务方法，调用OrderMapper的对应方法从数据库获取指定id的订单记录
    @Override
    public Order selectOrderById(Long id) {
        return orderMapper.selectOrderById(id);
    }
    // 更新商品信息的业务方法，调用GoodsMapper的对应方法将传入的商品对象信息更新到数据库中
    @Override
    public int updateOrder(Order order) {
        return orderMapper.updateOrder(order);
    }

    // 新增商品的业务方法，调用GoodsMapper的对应方法将传入的商品对象插入到数据库中
    @Override
    public void addOrder(Order order) {
        orderMapper.insertOrder(order);
    }

    // 根据商品id删除商品的业务方法，调用GoodsMapper的对应方法从数据库中删除指定id的商品记录
    @Override
    public void deleteOrderById(Long id) {
        orderMapper.deleteOrderById(id);
    }
}